<script type="text/javascript">
tinyMCE.init({
	mode : "exact",
	elements: "text_<?= $name;?>",
	content_css : "<?php echo static_url("style/estilo.css"); ?>",
	
	file_browser_callback : "ajaxfilemanager",
	
	relative_urls : true,
	remove_script_host : true,
	convert_urls : false,
	document_base_url : "<?php echo base_url(); ?>"
	
	<?php if(isset($properties['mode']) && $properties['mode']=="advanced"):?>
	,
	theme : "advanced",
	plugins : "safari,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,imagemanager,filemanager",

	// Theme options
	theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
	theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor",
	theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,print,|,ltr,rtl,|,fullscreen",
	theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,template,blockquote,pagebreak,|,insertfile,insertimage",
	theme_advanced_toolbar_location : "top",
	theme_advanced_toolbar_align : "left",
	theme_advanced_statusbar_location : "bottom",	
	theme_advanced_resizing : true
	<?php elseif(isset($properties['mode']) && $properties['mode']=="simple"):?>
	
	<?php else:?>
	
	<?php endif;?>
	

});

function ajaxfilemanager(field_name, url, type, win) {
	var ajaxfilemanagerurl = "<?php echo static_url("javascript/tinymce_3_2_3_1/jscripts/tiny_mce/plugins/ajaxfilemanager/ajaxfilemanager.php?editor=tinymce"); ?>";

	switch (type) {
		case "image":
			break;
		case "media":
			break;
		case "flash": 
			break;
		case "file":
			break;
		default:
			return false;
	}

      tinyMCE.activeEditor.windowManager.open({
          url: ajaxfilemanagerurl,
          width: 782,
          height: 500,
          inline : "yes",
          close_previous : "no"
      },{
          window : win,
          input : field_name
      });
}
</script>

<div id="<?= $name;?>" class="ctype-field">
<?php $conf_label = array(); ?>
	<?php if(form_error($name)): ?>
		<?php $conf_label['class'] = "input_error"; ?>
	<?php endif; ?>
			
	<?php $title_label = $properties['title']; ?>
<?php if(isset($required) && $required): ?>
	<?php $title_label .=  " *"; ?>
<?php endif; ?>
<?= form_label($title_label, $name, $conf_label);?>

<?php $value = set_value($name, $value); ?>

<textarea class="big" name="<?= $name;?>" id="text_<?= $name;?>" rows="<?= $properties['rows'];?>"><?php if(isset($value) && $value != NULL) echo $value;?></textarea>
</div>
